php submit form to self

Submitting form to self page is easy.Just what you have to do is set form action method to blank.Leaving form action blank will

submit form to itself.

For submitting php form itself keep your php code to top of php page and php html form code to bellow your php code.In your php code a top please use isset($_POST) condition so it only call when form postback is done.

<?php
  if(isset($_POST['YoursubmitButtunName']))
  {
          print_r($_POST);
     
     //Your insert/Update logic goes here
  
  
  }
?>

<html>
<head>
  <title>php how to self submit form</title>
</head>  
<body>
 <form name='frmYourFormName' method="post" action="" >
  
    <table>
       <tr>
          <td>  
             Field 1
          </td>
          <td>
            <input type="text" name='fld1' id="fld1">
          </td>
       </tr>
       <tr>   
          <td>  
             Field 2
          </td>
          <td>
            <input type="checkbox" name='checkboxName[]' id="checkboxName">Chk1 <br/>
            <input type="checkbox" name='checkboxName[]' id="checkboxName">Chk2 
            
          </td>
       </tr>
       <tr>   
          <td>  
             &nbsp;
          </td>
          <td>
            <input type="submit" name='YoursubmitButtunName' id="YoursubmitButtunName">
          </td>
       </tr>
    </table>
   
 </form>

</body>
</html>